<!--My 个人中心页-->
<template>
  <div class="my">
    <div class="first">
      <p style="text-align: center; color: #fff; font-size: 26px">我的信息</p>
      <div class="card">
        <div class="avatar">
          <img src="@/assets/avatar.jpg" />
        </div>
        <div class="nickname">{{ username }}</div>
        <div class="address">
          <van-cell title="地址" icon="location-o" />
        </div>
      </div>
    </div>
    <div class="content">
      <van-cell title="退出登录" is-link @click="logout" />
      <van-cell title="完善信息" is-link />
      <van-cell title="查看记录" is-link />
      <van-cell title="意见反馈" is-link />
    </div>
  </div>
</template>

<script>
import { reactive, toRefs } from 'vue'
import router from '@/router'
const logout = ()=>{
      // 退出登录的操作
      localStorage.removeItem('isLogin')
      // 去到首页或登录页
      router.push('/login')
    }


export default {
  setup() {
    const state = reactive({
      username: 'default'
    })
    state.username = localStorage.getItem('user')
    return {
      ...toRefs(state),
      logout
    }
  }
}
</script>

<style scoped>
.first {
  width: 100%;
  height: 13.75rem;
  background-color: bisque;
  position: relative;
  display: flex;
  justify-content: center;
}
.card {
  width: 90%;
  height: 10.625rem;
  border-radius: 0.625rem;
  background-color: #fff;
  position: absolute;
  bottom: -30px;
  box-shadow: 10px 10px 21px rgb(0 0 0 / 40%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.avatar {
  width: 7.5rem;
  height: 7.5rem;
  border-radius: 50%;
}
.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 30%;
}
.nickname {
  color: rgb(204, 202, 202);
  margin-top: 5px;
}
.van-cell {
  color: rgb(204, 202, 202);
}
.content {
  margin-top: 5rem;
}
</style>
